namespace DotConferenceSql
{
    /// <summary>
    /// Singleton to create DatabaseConnection instances.
    /// </summary>
    public class DatabaseManager
    {
        static readonly DatabaseManager instance = new DatabaseManager();

        /// <summary>
        /// Initializes the <see cref="DatabaseManager"/> class.
        /// </summary>
        static DatabaseManager()
        {
        }

        /// <summary>
        /// Get the single Instance of DbConnectionManager.
        /// Open the database if needed.
        /// </summary>
        public static DatabaseManager Instance
        {
            get
            {
                return instance;
            }
        }

        /// <summary>
        /// Gets a new DatabaseConnection which is already opened
        /// </summary>
        /// <returns>new DatabaseConnection</returns>
        public DatabaseConnection GetConnection()
        {
            DatabaseConnection newConnection = new DatabaseConnection();
            newConnection.Open();

            return newConnection;
        }
    }
}
